﻿@model IEnumerable<MasBankAccount>

@{
    ViewBag.Title = "ข้อมูลธนาคาร";
    ViewBag.Descr = "ข้อมูลบัญชีธนาคาร";
}

@using (Html.BeginForm("DeleteAll", "MasBankAccount", FormMethod.Post, new { id = "form" }))
{
    @Html.AntiForgeryToken()
    <div class="row-fluid">
        <div class="block-button-menu-above">
            @Html.ButtonAdd()
            @Html.ButtonDeleteAll()
        </div>

        @Html.ValidationSummary(true, "", new { @class = "alert alert-error" })

        <div class="row-fluid">
            <div class="table-header span12">
                <div class="span10">@ViewBag.Title</div>
                @Html.Partial("_ExportButton")
            </div>
        </div>

        <table id="table" class="table table-striped table-bordered table-hover" aria-describedby="table_info">
            <thead>
                <tr>
                    <th class="center" style="width: 50px;">
                        <label>
                            <input type="checkbox" />
                            <span class="lbl"></span>
                        </label>
                    </th>
                    <th>ประเภทบัญชีเงินฝาก :</th>
                    <th>เลขที่บัญชี :</th>
                    <th>แหล่งเงิน :</th>
                    <th>ชื่อบัญชีเงินฝาก :</th>
                    <th>ชื่อบัญชีเงินฝาก (EN) :</th>
                    <th>ธนาคาร :</th>
                    <th></th>
                </tr>
            </thead>

            <tbody>
                @foreach (var m in Model)
                {
              
                    <tr>
                        <td class="center">
                            <label>
                                <input type="checkbox" name="deleteIds" value="@(m.BankAccId)" />
                                <span class="lbl"></span>
                            </label>
                        </td>

                        <td>@Html.DisplayFor(modelItem => m.MasBankAccountType.Name)</td>
                        <td>@Html.DisplayFor(modelItem => m.BankAccNo)</td>
                        <td>@Html.DisplayFor(modelItem => m.MasBudgetSource.Name)</td>
                        <td>@Html.DisplayFor(modelItem => m.Name)</td>
                        <td>@Html.DisplayFor(modelItem => m.NameEng)</td>
                        <td>@Html.DisplayFor(modelItem => m.Branch.Bank.Name)</td>

                        <td class="td-actions">
							@Html.Partial("_ButtonMenuEachRow", new ExportGrid
								{
									Id=m.BankAccId, 
									DetailsUrl = Url.Action("Details") + "/" + m.BankAccId,
									EditUrl = Url.Action("Edit") + "/" + m.BankAccId,
									DeleteUrl = Url.Action("Delete") + "/" + m.BankAccId,
									
								})
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@section scripts {

    <script type="text/javascript">
        $(function () {
            var oTable1 = $('#table').dataTable({
                "aoColumns": [
                    { "bSortable": false },
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    { "bSortable": false }
                ]
            });

            $('table th input:checkbox').on('click', function () {
                var that = this;
                $(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function () {
				    this.checked = that.checked;
				    $(this).closest('tr').toggleClass('selected');
				});

            });

            $('[data-rel=tooltip]').tooltip();

            $("form").submit(function () {
                var currentForm = this;
                bootbox.confirm(function (result) {
                    var _result = result;
                    if (result) {
                        $.ajax({
                            url: "DeleteAll",
                            type: "post",
                            dataType: "json",
                            data: $(currentForm).serialize(),
                            success: function (result) {
                                if (result.success) {
                                    location.reload();
                                } else {
                                    //$("#Error").html('Error');
                                }
                            }
                        });
                    }
                })
                return false;
            });
        })
    </script>
}